package org.ssm.cas;

import org.springframework.security.crypto.password.PasswordEncoder;
import org.ssm.cas.utils.SecurityUtils;

/**
 * @author ssm
 */
public class PasswordEncryption implements PasswordEncoder {

    @Override
    public String encode(CharSequence charSequence) {
        String password = SecurityUtils.encryptPassword(charSequence.toString());
        return password;
    }

    @Override
    public boolean matches(CharSequence rawPassword, String encodePassword) {
        // 判断密码是否存在
        if (rawPassword == null) {
            return false;
        }
        return SecurityUtils.matchesPassword(rawPassword.toString(), encodePassword);
    }
}
